package com.key.modules.service.impl;

import com.key.modules.mapper.FirstPageMapper;
import com.key.modules.service.FirstPageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author：朕
 * @Package：com.key.modules.service.impl
 * @Project：logistics_system
 * @name：FirstPageServiceImpl
 * @Date：2023/3/23 20:13
 * @Filename：FirstPageServiceImpl
 */
@Service
public class FirstPageServiceImpl implements FirstPageService {

    @Autowired
    private FirstPageMapper firstPageMapper;

    /**
     * 今日订单总数
     * @return
     */
    @Override
    public Integer findIndentQuantityByToday() {
        return firstPageMapper.findIndentQuantityByToday();
    }

    /**
     * 查询运单总额
     * @return
     */
    @Override
    public Integer findWaybillMoneyByToday() {
         String f = firstPageMapper.findWaybillMoneyByToday();
         if(f==null){
             return 0;
         }
        return  Integer.parseInt(f);
    }

    /**
     * 查询今日支出总额
     * @return
     */
    @Override
    public Integer findPayMoneyByToday() {
        String f = firstPageMapper.findPayMoneyByToday();
        if(f==null){
            return 0;
        }
        return  Integer.parseInt(f);
    }

    /**
     * 根据日期查询订单数量
     * @return
     */
    @Override
    public List<Integer> findIndentQuantityByDate() {
        Integer today = firstPageMapper.findIndentQuantityByToday();
        Integer week = firstPageMapper.findIndentQuantityByWeek();
        Integer month = firstPageMapper.findIndentQuantityByMonth();
        List<Integer> list = new ArrayList<>();
        list.add(today);
        list.add(week);
        list.add(month);
        return list;
    }

    /**
     * 根据日期查询车次数量
     * @return
     */
    @Override
    public  List<Integer> findVehicleNumberTimeByDate() {
        Integer today = firstPageMapper.findVehicleNumberTimeByDay();
        Integer week = firstPageMapper.findIndentQuantityByWeek();
        Integer month = firstPageMapper.findVehicleNumberTimeByMonth();
        List<Integer> list = new ArrayList<>();
        list.add(today);
        list.add(week);
        list.add(month);
        return list;
    }
}
